﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>微街秀 > 已发记录</title>
    <link href="plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="css/css.css" />
    <link href="css/OrginArticle.css" rel="stylesheet" type="text/css" />
    <style>
        .tab{border-bottom: 1px solid gray;line-height: 46px;font-size: 16px;text-align: center;}
        .tab-active{border-bottom: 2px solid #F37B0B;color: #F37B0B;}
        .tab-fc-client{color: Gray;margin-left: -15px;margin-right: -15px;}
        .tab-fc-client .media{margin-left: 15px;margin-right: 15px;}
        .tab-fc-client .left-date{width: 85px;}
        .tab-fc-agent, .tab-fc-yy{margin-left: -15px;margin-right: -15px;}
        .fc-title{height: 42px;}
        .fc-num{line-height: 36px;padding-left: 26px;position: relative;color: #b0b0b0;}
        .fc-num > img{height: 25px;width: auto;position: absolute;left: 0px;top: 7px;}
        .bg-hui{background-color: #b0b0b0;}
        .gray{color: #b0b0b0;}
        .bb{border-bottom: 1px solid #d6d5d4;}
        .pl10 .pr10 div{width: 50px;height: 19px;}
    </style>
</head>
<body>
<div class="wamtop">
            <div class="topleft" onclick="window.location.href='publish.html'">
           
                    <img src="img/14.png"> </div>
            <div class="topcententxt">已发记录(<span id="count">0</span>)</div>
        </div>
    <div class="container-fluid">
        <div class="row">
            <div class="col-xs-4 tab" tab="1">
                已发记录</div>
            <div class="col-xs-4 tab" tab="2">
                原创记录</div>
            <div class="col-xs-4 tab" tab="3">
                转发记录</div>
        </div>
        <div class="tab-fc-client tg_select1" tabindex="1">         
        </div>
        <div class="tab-fc-agent tg_select2" tabindex="2">
        </div>
        <div class="tab-fc-yy tg_select3" tabindex="3">
        </div>
    </div>
    <input type="hidden" id="pagecount2" value="10" />
    <input type="hidden" id="pagecount3" value="10" />
    <!--<input type="hidden" id="countnum2" value="10" />-->
    <!--<input type="hidden" id="countnum3" value="10" />-->
    <script src="js/jquery-2.1.4.min.js" type="text/javascript"></script>
    <script src="js/dialog.js" type="text/javascript"></script>
    <script src="js/ajax-data.js" type="text/javascript"></script>
    <script src="js/base.js" type="text/javascript"></script>
    <script>
        var tag_cerent = 1, page = 1;
        var pagecount = "0", pagecount3, count1 = 0, count2 = 0, count3 = 0;

        $(function () {
            bindClick();
            init();
            $(window).bind("scroll", function () {
                //当滚动条滚动时
                var scollTop = $(this).scrollTop() + $(this).height();
                var scollH = $(document).height();

                if (scollH - scollTop < 100) {
                    if (wait.isShow) { return; } //如果正在加载，则返回  
                    page++;
                    if (tag_cerent == 1)
                        GetList1(page);
                    if (tag_cerent == 3)
                        GetList3(page);
                    else if (tag_cerent == 2)
                        GetList2(page);
                }
                return false;
            });
        });

        function init() {
            var tag = getQueryString("tag");
            if (tag == 2)
                $(".tab").eq(1).click();
            else if (tag == 3)
                $(".tab").eq(2).click();
            else
                $(".tab").eq(0).click();

            $(".back").bind("click", function () {
                if (document.referrer == null || document.referrer.toString().indexOf("fl_detail") > -1)
                    document.location.href = 'personal.html'
                else
                    goBack();
            });
        }

        //绑定点击事件
        function bindClick() {
            $(".tab").on("click", function () {
                $(".tab").removeClass("tab-active");
                $(this).addClass("tab-active");

                //得到选项卡序号
                var tabIndex = $(this).attr("tab");
                $("div[tabindex]").hide();
                $("div[tabindex = '" + tabIndex + "']").show();
                tag_cerent = tabIndex;
                $(".tg_select" + tag_cerent).html("");
                $("#count").html(0);
                page = 1;
                if (tag_cerent == 1)
                    GetList1(1);
                if (tag_cerent == 3)
                    GetList3(1);
                else if (tag_cerent == 2)
                    GetList2(1);
            });
        }

        //所有记录
        function GetList1(page2) {
            if (pagecount == "1") { return; }
            if (!islogin()) { window.location.href = 'login.html'; return; }
            ajax.GetSharelist("is_other=0&page_index=" + page, function (data) {
                if (data.code == "4") { Alert(data.msg.toString()); pagecount = "1"; return; }
                if (data.item.pageCount < page) {
                    if (pagecount == "0")
                        Alert('到底了！');
                    pagecount = "1"; return;
                }
                loadhtml_FL(data);
                count1 = data.item.itemCount;
                $("#count").html(count1);
            });
        }

        //原创记录
        function GetList2(page) {
            if ($("#pagecount" + tag_cerent).val() == "1") { return; }
            if (!islogin()) { window.location.href = 'login.html'; return; }
            var hannelid = '';
            var keyword = '';
            var param = "channel_id=" + hannelid + "&author_id=" + userid + "&key_word=" + keyword + "&page_index=" + page;
            ajax.getarticleList(param, function (data) {
                if (data.code == "4") { Alert(data.msg.toString()); $("#pagecount" + tag_cerent).val("1"); return; }
                if (data.item.pageCount > 0 && data.item.pageCount < page) {
                    if ($("#pagecount" + tag_cerent).val() == "0")
                        Alert('到底了！');
                    $("#pagecount" + tag_cerent).val("1"); return;
                }
                count2 = data.item.itemCount;
                $("#count").html(count2);
                loadhtml(data);
            });
        }

        //转发记录
        function GetList3(page) {
            if ($("#pagecount" + tag_cerent).val() == "1") { return; }
            if (!islogin()) { window.location.href = 'login.html'; return; }
            ajax.GetSharelist("is_other=1&page_index=" + page, function (data) {
                if (data.code == "4") { Alert(data.msg.toString()); $("#pagecount" + tag_cerent).val("1"); return; }
                if (data.item.pageCount > 0 && data.item.pageCount < page) {
                    if ($("#pagecount" + tag_cerent).val() == "0")
                        Alert('到底了！');
                    $("#pagecount" + tag_cerent).val("1"); return;
                }
                count3 = data.item.itemCount;
                $("#count").html(count3);
                loadhtml_ZF(data);
            });
        }

        function loadhtml(data) {
            $(data.item.table).each(function () {
                var logoimg = this.logo == null ? "img/30.png" : this.logo;
                var titles = this.title;
                if (titles.length > 12)
                    titles = titles.substr(0, 12) + "...";

                $(".tg_select" + tag_cerent).append("<div id='r2_" + this.id + "' class=\"centenlist\"><div class=\" centenimg\"><img src=\"" + logoimg + "\"  /></div><div class=\"cententxt\"  onclick=\"window.location.href='to_detail.aspx?article_id=" + this.id + "'\"><div class=\"cententxttop\"><strong>" + titles + "</strong></div><div class=\"centenTime\"><div class=\"centenpostion\">" + this.date.substr(0, 10) + "<div class=\"centenflow\">  <img src=\"img/flow.jpg\"> " + this.click + "</div></div><div id='d2_" + this.id + "' class=\"check\"><img src=\"img/Delete2.jpg\" class=\"checkimg\"/><input type=\"hidden\" name=\"checkid\" value=\"" + this.id + "\" /></div></div></div></div>");
            });
            BindDel();
        }
        function loadhtml_ZF(data) {
            $(data.item.table).each(function () {
                var logoimg = this.article_logo == null ? "img/30.png" : this.article_logo;
                var titles = "";
                if (this.type == 1)
                    titles = this.article_title;
                else if (this.type == 2) {
                    titles = this.url_title;
                    if (this.url_logo != null && this.url_logo != "")
                        logoimg = this.url_logo;
                }
                if (titles != null && titles.length > 12)
                    titles = titles.substr(0, 12) + "...";
                $(".tg_select" + tag_cerent).append("<div id='r3_" + this.id + "' class=\"centenlist\"><div class=\" centenimg\"><img src=\"" + logoimg + "\"  /></div><div class=\"cententxt\"  onclick=\"window.location.href='to_detail.aspx?shared_id=" + this.id + "'\"><div class=\"cententxttop\"><strong>" + titles + "</strong></div><div class=\"centenTime\"><div class=\"centenpostion\">" + this.date.substr(0, 10) + "<div class=\"centenflow\">  <img src=\"img/flow.jpg\"> " + this.click + "</div></div><div id='d3_" + this.id + "' class=\"check\"><img src=\"img/Delete2.jpg\" class=\"checkimg\"/><input type=\"hidden\" name=\"checkid\" value=\"" + this.id + "\" /></div></div></div></div>");
            });
            BindDel();
        }

        function loadhtml_FL(data) {
            $(data.item.table).each(function () {
                var logoimg = this.article_logo == null ? "img/30.png" : this.article_logo;
                var titles;
                if (this.type == 1)
                    titles = this.article_title;
                else if (this.type == 2) {
                    titles = this.url_title;
                    if (this.url_logo != null && this.url_logo != "")
                        logoimg = this.url_logo;
                }
                if (titles == null) titles = "";
                if (titles.length > 12)
                    titles = titles.substr(0, 12) + "...";

                var url = "detail.aspx?is_app=1&shareid=" + this.id + "&advert_id=" + this.advert_id + "&article_id=" + this.article_id + "&type=" + this.type;
                $(".tg_select" + tag_cerent).append("<div id='r1_" + this.id + "' class=\"centenlist\"><div class=\" centenimg\"><img src=\"" + logoimg + "\"  /></div><div class=\"cententxt\" onclick=\"window.location.href='" + url + "'\" ><div class=\"cententxttop\"><strong>" + titles + "</strong></div><div class=\"centenTime\">" + this.date.substr(0, 10) + "<div class=\"centenflow\" style='width:100px;' name=\"" + this.id + "\" > <div style='width: 50px;float: left;'  ><img src=\"img/flow.jpg\" class=\"imgclick\" name=\"" + this.id + "\" /> " + this.click + "</div> <div><img src=\"img/dianji1.png\"  class=\"imgclick\" name=\"" + this.id + "\" /> " + this.ad_click + "</div></div><div id='d1_" + this.id + "' name='d1_" + this.article_id + "' class=\"check\"><img src=\"img/Delete2.jpg\" class=\"checkimg\"  /><input type=\"hidden\" name=\"checkid\" value=\"" + this.id + "\" /></div></div></div></div>");
            });
            BindDel();
        }

        //删除事件
        function BindDel() {
            $(".check").click(function () {
                var id = this.id.replace("d" + tag_cerent + "_", "");
                if (tag_cerent == 1) {
                    var article_id = $(this).attr("name").replace("d1_", "");
                    DelItem1(id, article_id, null);
                }
                else if (tag_cerent == 2)
                    DelItem2(id);
                else if (tag_cerent == 3)
                    DelItem3(id);
                return false;
            });
        }
        //删所有
        function DelItem1(id, article_id) {
            if (!confirm("确认此文章吗？"))
                return false;
            if (!islogin()) { window.location.href = 'login.html'; return; }
            ajax.RemoveShare("id=" + id + "&article_id=" + article_id, function (data) {
                if (data.code == 0) {
                    $("#r1_" + id).hide(500);
                    $("#count").html(--count1);

//                    if (article_id > 0) {
//                        if (!confirm("文章已删除，原创记录是否一并也删除？"))
//                            return false;

//                        ajax.Detelearticle("id=" + article_id, function (data) {
//                            if (data.code == 0) {
//                                Alert("删除成功");
//                            }
//                            else {
//                                Alert("原创删除失败,请到原创列表中删除");
//                            }
//                        });
//                    }
                }
                else {
                    Alert(data.msg.toString());
                }
            });

            return false;
        }
        //删原创
        function DelItem2(id) {
            if (!confirm("删除原创后，所有转载的文章都会打不开，确认删除吗？"))
                return false;
            if (!islogin()) { window.location.href = 'login.html'; return; }
            ajax.Detelearticle("id=" + id, function (data) {
                if (data.msg.toString() == "成功") {
                    $("#r2_" + id).hide(500);
                    $("#count").html(--count2);
                }
                else {
                    Alert(data.msg.toString());
                }
            });
        }
        //删转发
        function DelItem3(id) {         
            if (!confirm("确认此转发文章吗？"))
                return false;
            if (!islogin()) { window.location.href = 'login.html'; return; }
            ajax.RemoveShare("id=" + id, function (data) {
                if (data.code == "0") {
                    $("#r3_" + id).hide(500);
                    $("#count").html(--count3);
                }
                else {
                    Alert(data.msg.toString());
                }
            });
        } 
    </script>
</body>
</html>
